<template>
	<!--  -->
	<view class="building-add">
		<view class="add-content">
			<navigator class="add-item" url="../../Public/People" hover-class="none">
				<view class="item-left">刑释解教人员<text>*</text></view>
				<view class="item-right">{{ userId_text }}</view>
			</navigator>
			<navigator class="add-item" url="../../Public/help" hover-class="none">
				<view class="item-left">帮教人<text>*</text></view>
				<view class="item-right">{{ educaterId_text }}</view>
			</navigator>
			<view class="add-item">
				<view class="item-left">罪名<text>*</text></view>
				<view class="item-right"><input v-model="accusation" placeholder-style="color:#999;font-size:26rpx" placeholder="请输入罪名" /></view>
			</view>
			<view class="add-item">
				<view class="item-left">改造所名称<text>*</text></view>
				<view class="item-right"><input v-model="jailName" placeholder-style="color:#999;font-size:26rpx" placeholder="请输入改造所名称" /></view>
			</view>
			<view class="add-item">
				<view class="item-left">释放日期<text>*</text></view>
				<view class="item-right" @click="show3=true">{{ acquittalDate }}</view>
			</view>
			<view class="add-item">
				<view class="item-left">备注</view>
				<view class="item-right"><textarea v-model="remark" placeholder-style="color:#999;font-size:26rpx" placeholder="请输入备注"></textarea></view>
			</view>
		</view>
		<view class="btn">
			<view class="btn-1" @click="handleSubmit">保存</view>
		</view>
		
		<u-toast ref="uToast" />
		<!-- 时间 -->
		<u-picker mode="time" v-model="show3" :params="params" @confirm="confirmInboundDate3"></u-picker>
	</view>
</template>

<script>
	export default{
		data() {
			return{
				show3:false,
				userId_text:'请选择',
				userId:'',
				remark:'',
				accusation:'',
				jailName:'',
				educaterId:'',
				educaterId_text:'请选择',
				acquittalDate:'请选择',
				params: {
					year: true,
					month: true,
					day: true
				},
			}
		},
		mounted() {
			
		},
		onShow() {
			let User = uni.getStorageSync('people')
			// console.log(User)
			this.userId_text = User.name
			this.userId = User.id
			let helpPer = uni.getStorageSync('helpPer')
			// console.log(User)
			this.educaterId_text = helpPer.name
			this.educaterId = helpPer.id
		},
		methods:{
			confirmInboundDate3(e) {
				this.acquittalDate = e.year + '-' + e.month + '-' + e.day
			},
			// 提交
			handleSubmit() {
				if(this.userId == '') {
					return this.$refs.uToast.show({
						title: '请选择刑释解教人员'
					})
				}
				if(this.educaterId == '') {
					return this.$refs.uToast.show({
						title: '请选择帮教人'
					})
				}
				if(this.accusation == '') {
					return this.$refs.uToast.show({
						title: '请填写罪名'
					})
				}
				if(this.jailName == '') {
					return this.$refs.uToast.show({
						title: '请填写改造所名称'
					})
				}
				if(this.acquittalDate == '请选择') {
					return this.$refs.uToast.show({
						title: '请选择释放日期'
					})
				}
				let params = {
					remark:this.remark,
					userId:this.userId,
					accusation:this.accusation,
					acquittalDate:this.acquittalDate,
					educaterId:this.educaterId,
					jailName:this.jailName
				}
				console.log(params)
				uni.removeStorageSync('people')
				uni.removeStorageSync('helpPer')
				this.$u.api.addPrisoner(params)
					.then(res => {
						console.log(res)
						if(res.code == 200) {
							uni.showToast({
								title:'添加成功',
								icon:'success'
							})
						}
					})
					.catch(err => {
						console.log(err)
						this.$refs.uToast.show({
							title: err.message
						})
					})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.building-add{
		background-color: #f5f6f7;
		min-height: 100vh;
		.gridcontent{
			height: 40vh;
			width: 100%;
			padding: 20rpx;
			color: #333;
			font-size: 27rpx;
			text-align: left;
			.item{
				width: 100%;
				padding: 5rpx 40rpx;
				overflow-y: auto;
				.item1{
					padding: 5rpx 40rpx;
					.item2{
						padding: 5rpx 40rpx;
						.item3{
							padding: 5rpx 40rpx;
							.item4{
								padding: 5rpx 40rpx;
								
							}
						}
					}
				}
			}
		}
		.add-head{
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			height: 180rpx;
			padding: 20rpx;
			.head-left{
				.head-left-1{
					color: #000;
					font-size: 28rpx;
					font-weight: 600;
				}
				.head-left-2{
					color: #999;
					font-size: 24rpx;
					margin-top: 20rpx;
				}
			}
			.head-right{
				background-color: #cecece;
				display: flex;
				justify-content: center;
				align-items: center;
				border-radius: 10rpx;
				width: 150rpx;
				height: 150rpx;
				.img{
					width: 50%;
					height: 50%;
				}
				.img2{
					width: 100%;
					height: 100%;
				}
			}
		}
		.add-content{
			margin-top: 20rpx;
			padding-bottom: 110rpx;
			.add-item{
				display: flex;
				// justify-content: space-between;
				align-items: flex-start;
				padding: 30rpx 20rpx;
				background-color: #fff;
				border-bottom: 1px solid #f4f1f1;
				.item-left{
					color: #333;
					font-size: 28rpx;
					flex: 2;
					text{
						color: #DD524D;
					}
				}
				.item-right{
					font-size: 27rpx;
					color: #999;
					display: flex;
					justify-content: flex-end;
					align-items: center;
					flex: 4;
					input{
						text-align: right;
					}
					input::placeholder{
					    font-size: 26rpx;
					    color: #999;
					}
					textarea{
						
					}
					text{
						display: inline-block;
						margin-left: 5rpx;
					}
				}
			}
		}
		.btn{
			width: 100%;
			height: 110rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			font-size: 30rpx;
			background-color: #f4f1f1;
			position: fixed;
			bottom: 0;
			left: 0;
			border-top: 1px solid #CCE6FF;
			.btn-1{
				background-color: #007AFF;
				display: flex;
				justify-content: center;
				align-items: center;
				width: 600rpx;
				height: 80rpx;
				border-radius: 40rpx;
			}
		}
	}
</style>
